<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:variable name="lowerCase" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upperCase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
	
<xsl:key name="classId" match="//Foundation.Core.Class[@xmi.id] | //Foundation.Core.AssociationClass[@xmi.id]" use="@xmi.id"/>
<xsl:key name="attributeId" match="//Foundation.Data_Types.Enumeration[@xmi.id] | //Foundation.Core.DataType[@xmi.id]" use="@xmi.id"/>
<xsl:key name="ImplementationId" match="//Foundation.Core.Interface[@xmi.id]" use="@xmi.id"/>
<xsl:key name="MultiplicityId" match="//Foundation.Core.Association/Foundation.Core.Association.connection/Foundation.Core.AssociationEnd[@xmi.id]/Foundation.Core.AssociationEnd.multiplicity/Foundation.Data_Types.Multiplicity[@xmi.id]" use="@xmi.id"/>

<xsl:key name="stereotypeId" match="//Foundation.Extension_Mechanisms.Stereotype[@xmi.id]" use="@xmi.id"/>
<xsl:key name="DataTypeId" match="//Foundation.Core.DataType[@xmi.id] | //Foundation.Core.Class[@xmi.id]" use="@xmi.id"/>


<xsl:template match="/">
<UMLEditor>
	<xsl:choose>
		<xsl:when test="//Model_Management.Model">
			<xsl:apply-templates select="//Model_Management.Model" />
		</xsl:when>
		<xsl:otherwise>
			<xsl:apply-templates select="//XMI.content/node()" mode="PartialModel" />
		</xsl:otherwise>
	</xsl:choose>
</UMLEditor>
</xsl:template>

<xsl:template match="*" mode="PartialModel">
	<xsl:element name="Model">
		<!-- Package -->
		<xsl:element name="Package">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 	
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
			
		<xsl:for-each select="Foundation.Core.Namespace.ownedElement/Foundation.Core.Class[@xmi.id]">
			<xsl:variable name="idclass" select="@xmi.id"/>

			<xsl:choose>
				<!-- test si la classe possède une stéréotype -->
				<xsl:when test="Foundation.Core.ModelElement.stereotype/Foundation.Extension_Mechanisms.Stereotype[@xmi.id]/Foundation.Extension_Mechanisms.Stereotype.extendedElement/Foundation.Core.ModelElement[@xmi.idref=$idclass]">
					
					<!-- Si oui : définition du stéréotype -->
					<xsl:variable name="stereotype" select="../Foundation.Extension_Mechanisms.Stereotype[@xmi.id]/Foundation.Extension_Mechanisms.Stereotype.extendedElement/Foundation.Core.ModelElement[@xmi.idref=$idclass]/../../Foundation.Core.ModelElement.name"/>
					
					<!-- Suivant le stéréotype .... -->
					<xsl:choose>
						<!-- Enumeration -->
						<xsl:when test="translate($stereotype,$upperCase,$lowerCase)='enumeration'">
							<xsl:apply-templates select="." mode="Enumeration"/>
						</xsl:when>
						
						<!-- Singleton -->
						<xsl:when test="translate($stereotype,$upperCase,$lowerCase)='singleton'">
							<xsl:apply-templates select="." mode="Singleton"/>
						</xsl:when>
					</xsl:choose>			
				</xsl:when>
				
				<xsl:otherwise>
					<!-- classe "normale" -->
					<xsl:apply-templates select="." mode="Class"/>
				</xsl:otherwise>
			</xsl:choose>
			
		</xsl:for-each>
		
		<!-- classe d'association -->
		<xsl:apply-templates select="Foundation.Core.Namespace.ownedElement/Foundation.Core.AssociationClass[@xmi.id]" mode="AssociationClass"/>
		
		<!-- interfaces -->
		<xsl:apply-templates select="Foundation.Core.Namespace.ownedElement/Foundation.Core.Namespace.ownedElement/Foundation.Core.Interface[@xmi.id]" mode="Interface"/>
		
	</xsl:element>
		
		<!-- Héritage -->
		<xsl:apply-templates select="//Foundation.Core.Generalization[@xmi.id]/Foundation.Core.Generalization.parent/child::node()/../.." mode="Generalisation"/>
		
		<!-- Implémentation -->
		<!-- Together-->
		<xsl:apply-templates select="//Foundation.Core.Generalization[@xmi.id]/Foundation.Core.Generalization.parent/Foundation.Core.Interface/../.." mode="Implementation_Together"/>
		<!-- ArgoUML-->
		<xsl:apply-templates select="//Foundation.Core.Abstraction[@xmi.id]" mode="Implementation_ArgoUml"/>

		
		<!-- Association -->
		<xsl:apply-templates select="//Foundation.Core.Association[@xmi.id]" mode="Association"/>
		<xsl:apply-templates select="//Foundation.Core.AssociationClass[@xmi.id]" mode="Association"/>
	</xsl:element>
</xsl:template>


<xsl:template match="Model_Management.Model" >
	<xsl:element name="Model">
		<!-- Package -->
		<xsl:apply-templates select="." mode="defaultPackage" />
		
		<!-- Héritage -->
		<xsl:apply-templates select="//Foundation.Core.Generalization[@xmi.id]/Foundation.Core.Generalization.parent/child::node()/../.." mode="Generalisation"/>
		
		<!-- Implémentation -->
		<!-- Together-->
		<xsl:apply-templates select="//Foundation.Core.Generalization[@xmi.id]/Foundation.Core.Generalization.parent/Foundation.Core.Interface/../.." mode="Implementation_Together"/>
		<!-- ArgoUML-->
		<xsl:apply-templates select="//Foundation.Core.Abstraction[@xmi.id]" mode="Implementation_ArgoUml"/>

		
		<!-- Association -->
		<xsl:apply-templates select="//Foundation.Core.Association[@xmi.id]" mode="Association"/>
		<xsl:apply-templates select="//Foundation.Core.AssociationClass[@xmi.id]" mode="Association"/>
	</xsl:element>
</xsl:template>

<!-- Model (Package) -->
<xsl:template match="Model_Management.Model" mode="defaultPackage">
	<xsl:element name="Package">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 	
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
			
		<xsl:for-each select="//Foundation.Core.Class[@xmi.id]">
			<xsl:variable name="idclass" select="@xmi.id"/>

			<xsl:choose>
				<!-- test si la classe possède une stéréotype -->
				<xsl:when test="../Foundation.Extension_Mechanisms.Stereotype[@xmi.id]/Foundation.Extension_Mechanisms.Stereotype.extendedElement/Foundation.Core.ModelElement[@xmi.idref=$idclass]">
					
					<!-- Si oui : définition du stéréotype -->
					<xsl:variable name="stereotype" select="../Foundation.Extension_Mechanisms.Stereotype[@xmi.id]/Foundation.Extension_Mechanisms.Stereotype.extendedElement/Foundation.Core.ModelElement[@xmi.idref=$idclass]/../../Foundation.Core.ModelElement.name"/>
					
					<!-- Suivant le stéréotype .... -->
					<xsl:choose>
						<!-- Enumeration -->
						<xsl:when test="translate($stereotype,$upperCase,$lowerCase)='enumeration'">
							<xsl:apply-templates select="." mode="Enumeration"/>
						</xsl:when>
						
						<!-- Singleton -->
						<xsl:when test="translate($stereotype,$upperCase,$lowerCase)='singleton'">
							<xsl:apply-templates select="." mode="Singleton"/>
						</xsl:when>
					</xsl:choose>			
				</xsl:when>
				
				<xsl:otherwise>
					<!-- classe "normale" -->
					<xsl:apply-templates select="." mode="Class"/>
				</xsl:otherwise>
			</xsl:choose>
			
		</xsl:for-each>
		
		<!-- classe d'association -->
		<xsl:apply-templates select="//Foundation.Core.AssociationClass[@xmi.id]" mode="AssociationClass"/>
		
		<!-- interfaces -->
		<xsl:apply-templates select="//Foundation.Core.Interface[@xmi.id]" mode="Interface"/>
		
	</xsl:element>
</xsl:template>

<!-- Model (Package) -->
<xsl:template match="Model_Management.Package">
	<xsl:element name="Package">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 	
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
			
		<xsl:for-each select="Foundation.Core.Namespace.ownedElement/Foundation.Core.Class[@xmi.id]">
			<xsl:variable name="idclass" select="@xmi.id"/>

			<xsl:choose>
				<!-- test si la classe possède une stéréotype -->
				<xsl:when test="Foundation.Core.ModelElement.stereotype/Foundation.Extension_Mechanisms.Stereotype[@xmi.id]/Foundation.Extension_Mechanisms.Stereotype.extendedElement/Foundation.Core.ModelElement[@xmi.idref=$idclass]">
					
					<!-- Si oui : définition du stéréotype -->
					<xsl:variable name="stereotype" select="../Foundation.Extension_Mechanisms.Stereotype[@xmi.id]/Foundation.Extension_Mechanisms.Stereotype.extendedElement/Foundation.Core.ModelElement[@xmi.idref=$idclass]/../../Foundation.Core.ModelElement.name"/>
					
					<!-- Suivant le stéréotype .... -->
					<xsl:choose>
						<!-- Enumeration -->
						<xsl:when test="translate($stereotype,$upperCase,$lowerCase)='enumeration'">
							<xsl:apply-templates select="." mode="Enumeration"/>
						</xsl:when>
						
						<!-- Singleton -->
						<xsl:when test="translate($stereotype,$upperCase,$lowerCase)='singleton'">
							<xsl:apply-templates select="." mode="Singleton"/>
						</xsl:when>
					</xsl:choose>			
				</xsl:when>
				
				<xsl:otherwise>
					<!-- classe "normale" -->
					<xsl:apply-templates select="." mode="Class"/>
				</xsl:otherwise>
			</xsl:choose>
			
		</xsl:for-each>
		
		<!-- classe d'association -->
		<xsl:apply-templates select="Foundation.Core.Namespace.ownedElement/Foundation.Core.AssociationClass[@xmi.id]" mode="AssociationClass"/>
		
		<!-- interfaces -->
		<xsl:apply-templates select="Foundation.Core.Namespace.ownedElement/Foundation.Core.Namespace.ownedElement/Foundation.Core.Interface[@xmi.id]" mode="Interface"/>
		
	</xsl:element>
</xsl:template>

<!-- Classes -->
<xsl:template match="Foundation.Core.Class" mode="Class">
	<xsl:element name="Class">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 	
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>		
		<xsl:apply-templates select="Foundation.Core.ModelElement.visibility" mode="GetModelElementVisibility" />		
		<xsl:apply-templates select="Foundation.Core.GeneralizableElement.isAbstract" mode="GetGeneralizableElementIsAbstract" />
		
		<xsl:attribute name="final">false</xsl:attribute>
		
		<xsl:apply-templates select="Foundation.Core.ModelElement.stereotype" mode="GetModelElementStereotype" />
		
		<xsl:attribute name="associationClass">false</xsl:attribute>
		
		<!-- Attributs -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Attribute[@xmi.id]" mode="Property"/>
		
		<!-- Operations -->
		<!--<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Operation[@xmi.id]" mode="Operation"/>-->
		
	</xsl:element>
</xsl:template>

<!-- Classe d'Association -->
<xsl:template match="Foundation.Core.AssociationClass" mode="AssociationClass">
	<xsl:element name="Class">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 	
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
		<xsl:apply-templates select="Foundation.Core.ModelElement.visibility" mode="GetModelElementVisibility" />			
		<xsl:apply-templates select="Foundation.Core.GeneralizableElement.isAbstract" mode="GetGeneralizableElementIsAbstract" />

		<xsl:attribute name="final">false</xsl:attribute>
		<xsl:apply-templates select="Foundation.Core.ModelElement.stereotype" mode="GetModelElementStereotype" />
		<xsl:attribute name="associationClass">true</xsl:attribute>
		
		<!-- Attributs -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Attribute[@xmi.id]" mode="Property"/>
		
		<!-- Operations -->
		<!--<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Operation[@xmi.id]" mode="Operation"/>-->
		
	</xsl:element>
</xsl:template>


<!-- Attributs -->
<xsl:template match="Foundation.Core.Attribute" mode="Property">
	<xsl:variable name="attributeName" select="Foundation.Core.ModelElement.name"/>
	
	<xsl:if test="not( starts-with($attributeName, 'lnk'))">
		<xsl:element name="Property">
			<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 	
			<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/>
			<xsl:apply-templates select="Foundation.Core.StructuralFeature.type/Foundation.Core.DataType" mode="GetDataType" />
			<xsl:apply-templates select="Foundation.Core.ModelElement.visibility" mode="GetModelElementVisibility" />
			<xsl:attribute name="static">???</xsl:attribute>
			<xsl:apply-templates select="Foundation.Core.Attribute.initialValue" mode="GetAttributeInitialValue" />
		</xsl:element>
	</xsl:if>
</xsl:template>

<!-- Operations -->
<xsl:template match="Foundation.Core.Operation" mode="Operation">
	<xsl:element name="Operation">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 	
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
		
		<xsl:choose>
			<xsl:when test="Foundation.Core.BehavioralFeature.parameter/Foundation.Core.Parameter/Foundation.Core.Parameter.kind[@xmi.value='return']">
				<xsl:apply-templates select="Foundation.Core.BehavioralFeature.parameter/Foundation.Core.Parameter/Foundation.Core.Parameter.kind[@xmi.value='return']/../Foundation.Core.Parameter.type/Foundation.Core.DataType" mode="GetDataType"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:attribute name="type">void</xsl:attribute>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:apply-templates select="Foundation.Core.ModelElement.visibility" mode="GetModelElementVisibility" />
		<xsl:attribute name="static">???</xsl:attribute>
		<xsl:attribute name="modifier">m_none</xsl:attribute>
		<xsl:attribute name="code"/>
		
		<xsl:apply-templates select="Foundation.Core.BehavioralFeature.parameter/Foundation.Core.Parameter/Foundation.Core.Parameter.kind[@xmi.value='in' or @xmi.value='inout']/.." mode="GetParameter" />		

	</xsl:element>
</xsl:template>


<!-- Interface -->
<xsl:template match="Foundation.Core.Interface" mode="Interface">
	<xsl:element name="Interface">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 	
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
		
		<xsl:apply-templates select="Foundation.Core.ModelElement.visibility" mode="GetModelElementVisibility" />
		
		<xsl:attribute name="final">???</xsl:attribute>
		
		<!-- Attributs -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Attribute[@xmi.id]" mode="Property"/>
		
		<!-- Operations -->
		<!--<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Operation[@xmi.id]" mode="Operation"/>-->
		
	</xsl:element>
</xsl:template>


<!-- Enumeration -->
<xsl:template match="Foundation.Core.Class" mode="Enumeration">
	<xsl:element name="Enumeration">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 	
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
		
		<xsl:apply-templates select="Foundation.Core.ModelElement.visibility" mode="GetModelElementVisibility" />		
		<xsl:attribute name="final">???</xsl:attribute>
		
		<!-- Literal -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Attribute[@xmi.id]" mode="Literal"/>
		
	</xsl:element>
</xsl:template>

<!-- literal -->
<xsl:template match="Foundation.Core.Attribute" mode="Literal">
	<xsl:element name="Property">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 			
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
		<xsl:attribute name="type"/>
		<xsl:attribute name="visibility"/>
		<xsl:attribute name="static"/>
		<xsl:attribute name="defaultValue"/>

	</xsl:element>
</xsl:template>

<!-- Singleton -->
<xsl:template match="Foundation.Core.Class" mode="Singleton">
	<xsl:element name="Class">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 		
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
		
		<xsl:apply-templates select="Foundation.Core.ModelElement.visibility" mode="GetModelElementVisibility" />	
		
		<xsl:attribute name="final">???</xsl:attribute>
		<xsl:apply-templates select="Foundation.Core.GeneralizableElement.isAbstract" mode="GetGeneralizableElementIsAbstract" />
		<xsl:attribute name="final">false</xsl:attribute>
		<xsl:apply-templates select="Foundation.Core.ModelElement.stereotype" mode="GetModelElementStereotype" />
	
		<xsl:attribute name="associationClass">false</xsl:attribute>
		<xsl:attribute name="isSingleton">true</xsl:attribute>
		
		<!-- Attributs -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Attribute[@xmi.id]" mode="Property"/>
		
	</xsl:element>
</xsl:template>



<!-- l'héritage -->
<xsl:template match="Foundation.Core.Generalization" mode="Generalisation">
	<xsl:element name="Generalization">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
		<xsl:variable name="idvalue1" select="Foundation.Core.Generalization.child/child::node()/@xmi.idref"/>
		<xsl:variable name="idvalue2" select="Foundation.Core.Generalization.parent/child::node()/@xmi.idref"/>
		<xsl:attribute name="clientClassName"><xsl:value-of select="key('classId',$idvalue1)/Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="supplierClassName"><xsl:value-of select="key('classId',$idvalue2)/Foundation.Core.ModelElement.name"/></xsl:attribute>
	</xsl:element>
</xsl:template>

<!-- l'implémentation (Together)-->
<xsl:template match="Foundation.Core.Generalization" mode="Implementation_Together">
	<xsl:element name="Implementation">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
		<xsl:variable name="idvalue1" select="Foundation.Core.Generalization.child/child::node()/@xmi.idref"/>
		<xsl:variable name="idvalue2" select="Foundation.Core.Generalization.parent/child::node()/@xmi.idref"/>
		<xsl:attribute name="clientClassName"><xsl:value-of select="key('classId',$idvalue1)/Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="supplierClassName"><xsl:value-of select="key('ImplementationId',$idvalue2)/Foundation.Core.ModelElement.name"/></xsl:attribute>
	</xsl:element>
</xsl:template>

<!-- l'implémentation (ArgoUML) -->
<xsl:template match="Foundation.Core.Abstraction" mode="Implementation_ArgoUml">
	<xsl:element name="Implementation">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
		<xsl:variable name="idvalue1" select="Foundation.Core.Dependency.client/Foundation.Core.Class/@xmi.idref"/>
		<xsl:variable name="idvalue2" select="Foundation.Core.Dependency.supplier/Foundation.Core.Class/@xmi.idref"/>
		<xsl:attribute name="clientClassName"><xsl:value-of select="key('classId',$idvalue1)/Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="supplierClassName"><xsl:value-of select="key('ImplementationId',$idvalue2)/Foundation.Core.ModelElement.name"/></xsl:attribute>
	</xsl:element>
</xsl:template>

<!-- l'Association -->
<xsl:template match="Foundation.Core.Association" mode="Association">
	<xsl:element name="Association">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 		
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
		<xsl:attribute name="type"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationType"/></xsl:attribute>
		<xsl:attribute name="navigable"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationNavigability"/></xsl:attribute>

		<xsl:variable name="client"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClient"/></xsl:variable>
		<xsl:variable name="supplier"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationSupplier"/></xsl:variable>

		<xsl:attribute name="associationClassifier"/>
		
		<xsl:attribute name="clientClassName">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClassName"><xsl:with-param name="role" select="$client"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="clientRole">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClientRoleName"><xsl:with-param name="role" select="$client"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="clientMultiplicity">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationMultiplicity"><xsl:with-param name="role" select="$client"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="clientQualifierName"/>
		<xsl:attribute name="clientQualifierType"/>
		<xsl:attribute name="supplierClassName">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClassName"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="supplierRole">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationRoleName"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="supplierMultiplicity">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationMultiplicity"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="supplierQualifierName"></xsl:attribute><!-- non défini -->
		<xsl:attribute name="supplierQualifierType"></xsl:attribute>
	</xsl:element>
</xsl:template>

<!-- l'Association avec classe d'association-->
<xsl:template match="Foundation.Core.AssociationClass" mode="Association">
	<xsl:element name="Association">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName"/> 
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"	/>
		<xsl:attribute name="type"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationType"/></xsl:attribute>
		<xsl:attribute name="navigable"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationNavigability"/></xsl:attribute>
		<xsl:variable name="client">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClient"/>
		</xsl:variable>
		<xsl:variable name="supplier">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationSupplier"/>
		</xsl:variable>
		<xsl:attribute name="associationClassifier"><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="clientClassName"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClassName"><xsl:with-param name="role" select="$client"/></xsl:apply-templates></xsl:attribute>
		<xsl:attribute name="clientRole"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClientRoleName"><xsl:with-param name="role" select="$client"/></xsl:apply-templates></xsl:attribute>
		<xsl:attribute name="clientMultiplicity"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationMultiplicity"><xsl:with-param name="role" select="$client"/></xsl:apply-templates></xsl:attribute>
		<xsl:attribute name="clientQualifierName"/>
		<xsl:attribute name="clientQualifierType"/>
		<xsl:attribute name="supplierClassName"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClassName"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates></xsl:attribute>
		<xsl:attribute name="supplierRole"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationRoleName"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates></xsl:attribute>
		<xsl:attribute name="supplierMultiplicity"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationMultiplicity"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates></xsl:attribute>
		<xsl:attribute name="supplierQualifierName"/>
		<!-- non défini -->
		<xsl:attribute name="supplierQualifierType"/>
	</xsl:element>
</xsl:template>

<!-- retourne le nom de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationName">
	<xsl:choose>
		<xsl:when test="../Foundation.Core.ModelElement.name != '' ">
			<xsl:value-of select="../Foundation.Core.ModelElement.name"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="../@xmi.id"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<!-- retourne le type de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationType">
	<xsl:variable name="class1" select="Foundation.Core.AssociationEnd[1]/Foundation.Core.AssociationEnd.aggregation/@xmi.value"/>
	<xsl:variable name="class2" select="Foundation.Core.AssociationEnd[2]/Foundation.Core.AssociationEnd.aggregation/@xmi.value"/>

	<xsl:choose>
		<xsl:when test="$class1='none' and $class2='none'">association</xsl:when>
		<xsl:when test="$class1='aggregate' or $class2='aggregate'">aggregation</xsl:when>
		<xsl:when test="$class1='composite' or $class2='composite'">composition</xsl:when>
	</xsl:choose>
</xsl:template>

<!-- retourne le client de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationClient">
	<xsl:variable name="class1" select="Foundation.Core.AssociationEnd[1]/Foundation.Core.AssociationEnd.aggregation/@xmi.value"/>

	<xsl:choose>
		<xsl:when test="$class1='none'">2</xsl:when>
		<xsl:otherwise>1</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<!-- retourne le supplier de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationSupplier">
	<xsl:variable name="class1" select="Foundation.Core.AssociationEnd[1]/Foundation.Core.AssociationEnd.aggregation/@xmi.value"/>

	<xsl:choose>
		<xsl:when test="$class1='none'">1</xsl:when>
		<xsl:otherwise>2</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<!-- retourne la navigabilité de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationNavigability">
	
	<xsl:variable name="client"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClient"/></xsl:variable>
	
	<xsl:variable name="clientNavigability" select="Foundation.Core.AssociationEnd[position()=$client]/Foundation.Core.AssociationEnd.isNavigable/@xmi.value"/>
	
	<xsl:variable name="associationType"><xsl:apply-templates select="." mode="GetAssociationType"/></xsl:variable>
	
	<xsl:choose>
		<xsl:when test="$associationType='association'">false</xsl:when>
		<xsl:otherwise>
			<xsl:choose>
				<xsl:when test="$clientNavigability='true'">false</xsl:when>
				<xsl:otherwise>true</xsl:otherwise>
			</xsl:choose>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<!-- retourne le nom de la classe client/supplier de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationClassName">
	<xsl:param name="role"/>
	
	<!-- XMI 1.3 ARGO UML-->
	<!--<xsl:variable name="clientId" select="Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.type/Foundation.Core.Classifier/@xmi.idref | Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.type/Foundation.Core.AssociationClass/@xmi.idref"/>-->

	<!-- XMI 1.3 TOGETHER -->
	<!--<xsl:variable name="clientId" select="Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.type/Foundation.Core.Class/@xmi.idref | Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.type/Foundation.Core.AssociationClass/@xmi.idref"/>-->

	<xsl:variable name="clientId" select="Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.type/child::node()/@xmi.idref | Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.type/Foundation.Core.AssociationClass/@xmi.idref"/>

	<xsl:value-of select="key('classId', $clientId)/Foundation.Core.ModelElement.name"/>	
</xsl:template>

<!-- retourne le role du client/supplier de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationRoleName">
	<xsl:param name="role"/>
	
	<xsl:value-of select="Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.ModelElement.name"/>
</xsl:template>

<!-- retourne le role du client de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationClientRoleName">
	<xsl:param name="role"/>
	
	<xsl:choose>
		<xsl:when test="Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.ModelElement.name = 'undefined'">
			<xsl:variable name="roleSupplier"><xsl:apply-templates select="." mode="GetAssociationSupplier"/></xsl:variable>
			<xsl:apply-templates select="." mode="GetAssociationClassName"><xsl:with-param name="role" select="$role"/></xsl:apply-templates>
			<xsl:value-of select="Foundation.Core.AssociationEnd[position()=$roleSupplier]/Foundation.Core.ModelElement.name" />
			<xsl:text>Parent</xsl:text>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.ModelElement.name"/>	
		</xsl:otherwise>
	</xsl:choose>
	
</xsl:template>


<!-- retourne la multiplicité du client/supplier de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationMultiplicity">
	<xsl:param name="role"/>
	
	<xsl:variable name="lv">
		<!-- XMI 1.3 ARGO UML -->
		<xsl:if test="./Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.multiplicity/Foundation.Data_Types.Multiplicity[@xmi.id or @xmi.idref]">
			<xsl:variable name="idvalue" select="./Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.multiplicity/Foundation.Data_Types.Multiplicity/@xmi.id | ./Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.multiplicity/Foundation.Data_Types.Multiplicity/@xmi.idref"/>
	
			<xsl:value-of select="key('MultiplicityId',$idvalue)/Foundation.Data_Types.Multiplicity.range/Foundation.Data_Types.MultiplicityRange/Foundation.Data_Types.MultiplicityRange.lower"/>
		</xsl:if>
		
		<!-- XMI 1.3 TOGETHER -->
		<xsl:if test="not(./Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.multiplicity/Foundation.Data_Types.Multiplicity[@xmi.id or @xmi.idref])">
			<xsl:value-of select="./Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.multiplicity/Foundation.Data_Types.Multiplicity/Foundation.Data_Types.Multiplicity.range/Foundation.Data_Types.MultiplicityRange/Foundation.Data_Types.MultiplicityRange.lower"/>
		</xsl:if>
	</xsl:variable>
	
		<xsl:variable name="uv">
		<!-- XMI 1.3 ARGO UML -->
		<xsl:if test="./Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.multiplicity/Foundation.Data_Types.Multiplicity[@xmi.id or @xmi.idref]">
			<xsl:variable name="idvalue" select="./Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.multiplicity/Foundation.Data_Types.Multiplicity/@xmi.id | ./Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.multiplicity/Foundation.Data_Types.Multiplicity/@xmi.idref"/>
	
			<xsl:value-of select="key('MultiplicityId',$idvalue)/Foundation.Data_Types.Multiplicity.range/Foundation.Data_Types.MultiplicityRange/Foundation.Data_Types.MultiplicityRange.upper"/>
		</xsl:if>
		
		<!-- XMI 1.3 TOGETHER -->
		<xsl:if test="not(./Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.multiplicity/Foundation.Data_Types.Multiplicity[@xmi.id or @xmi.idref])">
			<xsl:value-of select="./Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.multiplicity/Foundation.Data_Types.Multiplicity/Foundation.Data_Types.Multiplicity.range/Foundation.Data_Types.MultiplicityRange/Foundation.Data_Types.MultiplicityRange.upper"/>
		</xsl:if>
	</xsl:variable>
	
	
	<xsl:variable name="upperValue">
		<xsl:choose>
			<xsl:when test="$uv='-1'">*</xsl:when>
			<xsl:otherwise><xsl:value-of select="$uv"/></xsl:otherwise>
		</xsl:choose>
	</xsl:variable>

	<xsl:variable name="xmiMultiplicity">
		<xsl:value-of select="$lv"/>
		<xsl:text>..</xsl:text>
		<xsl:value-of select="$upperValue"/>		
	</xsl:variable>

	<xsl:choose>
		<xsl:when test="$xmiMultiplicity='1..1'">1</xsl:when>
		<xsl:otherwise><xsl:value-of select="$xmiMultiplicity"/></xsl:otherwise>
	</xsl:choose>
	
</xsl:template>

<!-- ***************************************** DTD UML 1.3 ***************************************************************** -->
<xsl:template match="Foundation.Core.ModelElement.name" mode="GetModelElementName" >
	<xsl:choose>
		<xsl:when test="current() = '' or current() = 'undefined' ">
			<xsl:attribute name="name"><xsl:value-of select="../@xmi.id"/></xsl:attribute>
		</xsl:when>
		<xsl:otherwise>
			<xsl:attribute name="name"><xsl:value-of select="."/></xsl:attribute>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="Foundation.Core.ModelElement.visibility" mode="GetModelElementVisibility" >
	<xsl:choose>
		<xsl:when test=".">
			<xsl:attribute name="visibility">v_<xsl:value-of select="@xmi.value"/></xsl:attribute>
		</xsl:when>
		<xsl:otherwise>
			<xsl:attribute name="visibility">v_private</xsl:attribute>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="Foundation.Core.GeneralizableElement.isRoot" mode="GetGeneralizableElementIsRoot" >
	<xsl:attribute name="isRoot"><xsl:value-of select="@xmi.value"/></xsl:attribute>
</xsl:template>

<xsl:template match="Foundation.Core.GeneralizableElement.isAbstract" mode="GetGeneralizableElementIsAbstract" >
	<xsl:attribute name="abstract"><xsl:value-of select="@xmi.value"/></xsl:attribute>
</xsl:template>

<xsl:template match="Foundation.Core.GeneralizableElement.isLeaf" mode="GetGeneralizableElementIsLeaf" >
	<xsl:attribute name="isLeaf"><xsl:value-of select="@xmi.value"/></xsl:attribute>
</xsl:template>

<xsl:template match="Foundation.Core.Class.isActive" mode="GetClassIsActive" >
	<xsl:attribute name="isActive"><xsl:value-of select="@xmi.value"/></xsl:attribute>
</xsl:template>

<!-- retourne la documentation d'une entitée -->
<xsl:template match="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation">
	<xsl:attribute name="documentation">
		<xsl:value-of select="Foundation.Extension_Mechanisms.TaggedValue[Foundation.Extension_Mechanisms.TaggedValue.tag = 'documentation']/Foundation.Extension_Mechanisms.TaggedValue.value"/>
	</xsl:attribute>
</xsl:template>

<xsl:template match="Foundation.Core.ModelElement.stereotype" mode="GetModelElementStereotype">
	<xsl:variable name="idstereotype" select="Foundation.Extension_Mechanisms.Stereotype/@xmi.idref"/>
	<xsl:attribute name="stereotype"><xsl:value-of select="key('stereotypeId', $idstereotype)/Foundation.Core.ModelElement.name"/></xsl:attribute>
</xsl:template>

<xsl:template match="Foundation.Core.Attribute.initialValue" mode="GetAttributeInitialValue">
	<xsl:attribute name="defaultValue"><xsl:value-of 	select="Foundation.Core.Attribute.initialValue/Foundation.Data_Types.Expression/Foundation.Data_Types.Expression.body"/></xsl:attribute>	
</xsl:template>

<xsl:template match="Foundation.Core.DataType" mode="GetDataType">
	<xsl:variable name="idvalue" select="@xmi.idref"/>
					
	<xsl:choose>
		<!-- si le type n'est pas défini -->
		<xsl:when test="key('DataTypeId',$idvalue)/Foundation.Core.ModelElement.name = '' or key('DataTypeId',$idvalue)/Foundation.Core.ModelElement.name = '&amp;lt;undefined&amp;gt;'">
			<xsl:attribute name="type">void</xsl:attribute>
		</xsl:when>
		<xsl:when test="key('DataTypeId',$idvalue)/Foundation.Core.ModelElement.name = 'integer'">
			<xsl:attribute name="type">int</xsl:attribute>
		</xsl:when>
		<xsl:when test="key('DataTypeId',$idvalue)/Foundation.Core.ModelElement.name = 'boolean'">
			<xsl:attribute name="type">bool</xsl:attribute>
		</xsl:when>
		<xsl:when test="key('DataTypeId',$idvalue)/Foundation.Core.ModelElement.name = 'real'">
			<xsl:attribute name="type">float</xsl:attribute>
		</xsl:when>
		<!-- si le type est défini -->
		<xsl:otherwise>
			<xsl:attribute name="type"><xsl:value-of select="key('DataTypeId',$idvalue)/Foundation.Core.ModelElement.name"/></xsl:attribute>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="Foundation.Core.Parameter" mode="GetParameter">
	<xsl:element name="Parameter">
		<xsl:apply-templates select="Foundation.Core.ModelElement.name" mode="GetModelElementName" />
		<xsl:apply-templates select="Foundation.Core.Parameter.type/Foundation.Core.DataType" mode="GetDataType" />
		<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation" />		
	</xsl:element>
</xsl:template>




</xsl:stylesheet>
